//
// Created by twetec on 25-7-3.
//

#include "perception_rpc_caller_instruction.h"

#include <grpcpp/grpcpp.h>
#include <grpcpp/support/client_interceptor.h>
#include <boost/lockfree/spsc_queue.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/json.hpp>
#include <time.h>
#include <unistd.h>
#include <sys/time.h>

#include <asio2/asio2.hpp>

#include <network_prober/utils/snowflake_uuid_generator.h>
#include <network_prober/sys_config/sys_config.h>
#include <network_prober/database/memory_db_holder.h>
#include <network_prober/database/file_db_holder.h>
#include <network_prober/probe_detect/handle_icmp_probe_detect.h>
#include <network_prober/probe_detect/handle_tcp_probe_detect.h>
#include <network_prober/probe_detect/handle_udp_probe_detect.h>
#include <network_prober/probe_detect/handle_http_probe_detect.h>
#include <network_prober/probe_detect/handle_https_probe_detect.h>
#include <network_prober/probe_detect/handle_mysql_probe_detect.h>
#include <network_prober/probe_detect/handle_postgresql_probe_detect.h>
#include <network_prober/probe_detect/handle_sqlserver_probe_detect.h>
#include <network_prober/probe_detect/handle_mongodb_probe_detect.h>
#include <network_prober/probe_detect/handle_redis_probe_detect.h>
#include <network_prober/backup_test/handle_ssh_backup_test.h>
#include <network_prober/backup_test/handle_telnet_backup_test.h>

namespace network_prober::rpc
{
/**
 * 指令类型
 */
enum class InstructionType : std::uint8_t   // 默认32位，在这里只用8位就可以
{
    RESPONSE_RESULTS                    = 0, // 响应结果 {"code": 20000, "msg": "success"}

    OPEN_PROBE                          ,  // 开启探针 {"probeTasks":[{"UUID":"uuid","interface":"192.168.0.1","address":"192.168.0.101","port":8848,"protocol":1,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}],"backupTasks":[{"UUID":"uuid","interface":"192.168.0.1","address":"172.16.0.1","backupDate":"12:30","command":"show","protocol":1,"account":"admin","password":"1008611@rpc","privilegedPassword":"QwEr1023","port":8089}]}
    CLOSE_PROBE                         ,  // 关闭探针 {}

    OPEN_NETWORK                        ,  // 开启网口 {"probeTasks":[{"UUID":"uuid","interface":"192.168.0.1","address":"192.168.0.101","port":8848,"protocol":1,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}],"backupTasks":[{"UUID":"uuid","interface":"192.168.0.1","address":"172.16.0.1","backupDate":"12:30","command":"show","protocol":1,"account":"admin","password":"1008611@rpc","privilegedPassword":"QwEr1023","port":8089}]}
    CLOSE_NETWORK                       ,  // 关闭网口 {"probeTaskUUID":["uuid","uuid","uuid"],"backupTaskUUID":["uuid","uuid","uuid"]}

    PROBE_DETECT_ICMP_IPV4              ,  // 探测ICMP_Ipv4 {"interface":"192.168.0.1", "targets": "172.0.1.2, 192.168.0.102"}
    PROBE_DETECT_TCP_IPV4               ,  // 探测TCP_Ipv4  {"interface":"192.168.0.1", "targets": "172.0.1.2:80, 192.168.0.102:8000"}
    PROBE_DETECT_UDP_IPV4               ,  // 探测UDP_Ipv4  {"interface":"192.168.0.1", "targets": "172.0.1.2:9090, 192.168.0.102:3000"}
    PROBE_DETECT_ICMP_IPV6              ,  // 探测ICMP_Ipv6 {"interface":"192.168.0.1", "targets": "172.0.1.2:1200, 192.168.0.102"}
    PROBE_DETECT_TCP_IPV6               ,  // 探测TCP_Ipv6  {"interface":"192.168.0.1", "targets": "172.0.1.2:8520, 192.168.0.102:8080"}
    PROBE_DETECT_UDP_IPV6               , // 探测TCP_Ipv6  {"interface":"192.168.0.1", "targets": "172.0.1.2:8520, 192.168.0.102:8080"}

    PIPE_MANAGEMENT_PROBE_TARGETS       , // 纳管探测目标 [{"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"protocol":1,"responseCode":"","ignoreTsl":false,"requestMethod":"","requestHeader":"","requestBody":"","responseChallenge":false,"userName":"","password":"","databaseName":"","queryStatement":""}]

    ADD_HTTP_IPV4_PROBE_TARGET          , // 添加HTTP_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_HTTP_IPV6_PROBE_TARGET          , // 添加HTTP_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_HTTPS_IPV4_PROBE_TARGET         , // 添加HTTPS_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_HTTPS_IPV6_PROBE_TARGET         , // 添加HTTPS_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_ICMP_IPV4_PROBE_TARGET          , // 添加ICMP_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_ICMP_IPV6_PROBE_TARGET          , // 添加ICMP_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_TCP_IPV4_PROBE_TARGET           , // 添加TCP_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_TCP_IPV6_PROBE_TARGET           , // 添加TCP_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_UDP_IPV4_PROBE_TARGET           , // 添加UDP_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_UDP_IPV6_PROBE_TARGET           , // 添加UDP_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_POSTGRESQL_IPV4_PROBE_TARGET    , // 添加POSTGRESQL_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_POSTGRESQL_IPV6_PROBE_TARGET    , // 添加POSTGRESQL_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_SQLSERVER_IPV4_PROBE_TARGET     , // 添加SQLSERVER_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_SQLSERVER_IPV6_PROBE_TARGET     , // 添加SQLSERVER_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_MYSQL_IPV4_PROBE_TARGET         , // 添加MYSQL_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_MYSQL_IPV6_PROBE_TARGET         , // 添加MYSQL_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_MONGODB_IPV4_PROBE_TARGET       , // 添加MONGODB_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_MONGODB_IPV6_PROBE_TARGET       , // 添加MONGODB_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_REDIS_IPV4_PROBE_TARGET         , // 添加REDIS_IPV4观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    ADD_REDIS_IPV6_PROBE_TARGET         , // 添加REDIS_IPV6观测目标 {"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}

    UPDATE_HTTP_IPV4_PROBE_TARGET       , // 更新HTTP_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_HTTP_IPV6_PROBE_TARGET       , // 更新HTTP_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_HTTPS_IPV4_PROBE_TARGET      , // 更新HTTPS_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_HTTPS_IPV6_PROBE_TARGET      , // 更新HTTPS_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_ICMP_IPV4_PROBE_TARGET       , // 更新ICMP_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_ICMP_IPV6_PROBE_TARGET       , // 更新ICMP_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_TCP_IPV4_PROBE_TARGET        , // 更新TCP_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_TCP_IPV6_PROBE_TARGET        , // 更新TCP_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_UDP_IPV4_PROBE_TARGET        , // 更新UDP_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_UDP_IPV6_PROBE_TARGET        , // 更新UDP_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_POSTGRESQL_IPV4_PROBE_TARGET , // 更新POSTGRESQL_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_POSTGRESQL_IPV6_PROBE_TARGET , // 更新POSTGRESQL_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_SQLSERVER_IPV4_PROBE_TARGET  , // 更新SQLSERVER_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_SQLSERVER_IPV6_PROBE_TARGET  , // 更新SQLSERVER_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_MYSQL_IPV4_PROBE_TARGET      , // 更新MYSQL_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_MYSQL_IPV6_PROBE_TARGET      , // 更新MYSQL_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_MONGODB_IPV4_PROBE_TARGET    , // 更新MONGODB_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_MONGODB_IPV6_PROBE_TARGET    , // 更新MONGODB_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_REDIS_IPV4_PROBE_TARGET      , // 更新REDIS_IPV4观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    UPDATE_REDIS_IPV6_PROBE_TARGET      , // 更新REDIS_IPV6观测目标 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}

    OPEN_PROBE_TARGET                   , // 开启观测目标 {"UUID":"uuid", "interface":"192.168.0.10","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    CLOSE_PROBE_TARGET                  , // 关闭观测目标 {"UUID":"uuid"}

    DELETE_PROBE_TARGET                 , // 删除观测目标 {"UUID":"uuid"}
    BATCH_DELETE_PROBE_TARGET           , // 批量删除观测目标 ["uuid", "uuid", "uuid"]
    BATCH_IMPORT_PROBE_TARGET           , // 导入观测目标
    DETAILS_PROBE_TARGET                , // 设备详情(趋势图) {"startTime":"1752871150", "endTime":"1752871150", targets:["uuid", "uuid"]}

    DOMAIN_NAME_RESOLUTION              , // 域名解析 {"domainName":"www.baidu.com"}
    TIME_SYNCHRONIZATION                , // 时间同步 {"time":"1723256523"}

    TEST_TELNET_IPV4_BACKUP_TARGET      , // 测试Telnet_Ipv4备份目标 {"address":"192.168.0.1","interface":"192.168.0.101","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    TEST_TELNET_IPV6_BACKUP_TARGET      , // 测试Telnet_Ipv6备份目标 {"address":"192.168.0.1","interface":"192.168.0.101","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    TEST_SSH_IPV4_BACKUP_TARGET         , // 测试SSH_Ipv4备份目标    {"address":"192.168.0.1","interface":"192.168.0.101","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    TEST_SSH_IPV6_BACKUP_TARGET         , // 测试SSH_Ipv6备份目标    {"address":"192.168.0.1","interface":"192.168.0.101","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}

    ADD_TELNET_IPV4_BACKUP_TARGET       , // 添加Telnet_Ipv4备份目标 {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"doihvioahviooa nvjnopnfvk poa jpvn   povjnin pon"}
    ADD_TELNET_IPV6_BACKUP_TARGET       , // 添加Telnet_Ipv6备份目标 {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"doihvioahviooa nvjnopnfvk poa jpvn   povjnin pon"}
    ADD_SSH_IPV4_BACKUP_TARGET          , // 添加SSH_Ipv4备份目标    {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"doihvioahviooa nvjnopnfvk poa jpvn   povjnin pon"}
    ADD_SSH_IPV6_BACKUP_TARGET          , // 添加SSH_Ipv6备份目标    {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"doihvioahviooa nvjnopnfvk poa jpvn   povjnin pon"}

    UPDATE_TELNET_IPV4_BACKUP_TARGET    , // 修改Telnet_Ipv4备份目标 {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"WASN GHDFdxfhnjfthn ahxn"}
    UPDATE_TELNET_IPV6_BACKUP_TARGET    , // 修改Telnet_Ipv6备份目标 {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"WASN GHDFdxfhnjfthn ahxn"}
    UPDATE_SSH_IPV4_BACKUP_TARGET       , // 修改SSH_Ipv4备份目标    {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"WASN GHDFdxfhnjfthn ahxn"}
    UPDATE_SSH_IPV6_BACKUP_TARGET       , // 修改SSH_Ipv6备份目标    {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080,"backupData":"WASN GHDFdxfhnjfthn ahxn"}

    DELETE_BACKUP_TARGET                , // 删除备份目标 {"UUID":"uuid"}
    BATCH_IMPORT_BACKUP_TARGET           // 导入备份目标
};

/**
 * 目标探测协议
 */
enum class ProbeProtocol : std::uint8_t
{
    HTTPS = 1,
    ICMP,
    TCP,
    UDP,
    POST_GRE_SQL,
    SQL_SERVER,
    MY_SQL,
    MONGO_DB,
    REDIS,
    HTTP
};

/**
 * 接收的指令
 */
struct RecvInstruction
{
    InstructionType instructionType;    // 指令类型
    std::string payload;    // 指令负载

    // RecvInstruction() = default;    // 默认构造函数
    // RecvInstruction(RecvInstruction&&) = default;   // 可以复制或可移动
    // RecvInstruction& operator=(RecvInstruction&&) = default;
    // RecvInstruction(const RecvInstruction&) = default;
};

/**
 * 指令队列(全局)，缓存10个指令。处理的时候是等1个处理完返回后，再处理下一个
 */
static boost::lockfree::spsc_queue<RecvInstruction, boost::lockfree::capacity<10>> g_instructionSpscQueue;

InstructionCallerRPCClientReactor::InstructionCallerRPCClientReactor(network_perception::rpc::NetworkPerceptionServer::Stub *RPCClientStubPtr)
{
    // 将clientContext和自己传入RPC的方法(将自己与通道接通，这样就可以收发消息)
    RPCClientStubPtr->async()->instruction(std::addressof(m_clientContext), this);
}

/**
 * 当一次写入完成时调用 (向服务器发送)
 * @param ok 写入是否成功执行
 */
void InstructionCallerRPCClientReactor::OnWriteDone(bool ok)
{
    SPDLOG_INFO("===== OnWriteDone: {} =====", ok);

    if (ok) {
        // 如果一次写入成功，我们将添加一次写入
        // 如果写入完成，则调用StartWriteDone()
        // StartWrite(&m_instructionRequest);
        // StartWritesDone();
    }
}

/**
 * 当一次读取完成时调用(接收指令)
 * @param ok 读取是否成功执行
 */
void InstructionCallerRPCClientReactor::OnReadDone(bool ok)
{
    SPDLOG_INFO("===== OnReadDone：{} =====", ok);

    // 如果接收到的指令正常
    if (ok) {
        // 如果指令接收正常，则将指令解析并放入指令队列，等待执行
        RecvInstruction recvInstruction;
        recvInstruction.instructionType = static_cast<InstructionType>(instructionResponse.instruction());
        recvInstruction.payload = instructionResponse.data();

        // 等待队列空闲时，将指令压入队列 (尝试压入指令队列，直到成功)
        while (!g_instructionSpscQueue.push(std::move(recvInstruction))) {}

        // 持续尝试从服务端读取指令 （阻塞，等待服务端返回消息，再调用OnReadDone()）
        StartRead(&instructionResponse);
    }
}

/**
 * 响应RPC完成。检查RPC状态结果，等待grpc调用完成
 * 服务端断开连接，不会调用此方法。正常结束才会
 */
void InstructionCallerRPCClientReactor::OnDone(const grpc::Status& status)
{
    // 如果没正常结束，可以拿到错误信息
    // status.error_message()
    SPDLOG_INFO("===== Instruction caller结束（OnDone）: {} =====", status.ok());
    std::unique_lock<std::mutex> lock(m_mutex);
    m_callingDone = true;
    m_callingStatus = status;
    m_condition.notify_one();
}

grpc::Status InstructionCallerRPCClientReactor::awaitCallingDone()
{
    std::unique_lock<std::mutex> lock(m_mutex);
    m_condition.wait(lock, [this]{ return m_callingDone; });
    SPDLOG_INFO("指令处理 双向流通道关闭：{}", m_callingStatus.ok()? "正常结束" : m_callingStatus.error_message());
    return std::move(m_callingStatus);
}

void InstructionCallerRPCClientReactor::startCalling()
{
    // 发送第一次连接，主要向平台提交secretKey，进行身份认证
    // 如果在RPC启动时，要发送的内容，如果没有则需要调用StartWritesDone()来通知服务器我们已完成写入
    // 指令类型
    instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 指令数据 {"secretKey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTIxMzIzMDgsIm5iZiI6MTc1MTUyNzUwOCwiaWF0IjoxNzUxNTI3NTA4LCJ1c2VyX2lkIjoxLCJwcm9iZV9pZCI6IiJ9.NXVfj1JFAENlRxOiDUMbX9z0dYvaY6ih1WDSIeg0C8M"}
    boost::json::object data = {
        {"secretKey" , sys_config::SysConfig::getInstance().proberSecretKey()}
    };
    instructionRequest.set_data(boost::json::serialize(data));

    // auto resp = m_instructionRequest.mutable_response();
    // resp->set_secretkey(sys_config::SysConfig::getInstance().proberSecretKey());
    this->StartWrite(&instructionRequest);

    // 添加一个读取操作
    this->StartRead(&instructionResponse);

    // 建立并激活指令连接rpc
    this->StartCall();
}

/**
 * 拦截器，用于感知主机验证
 */
class PerceptionHostAuthInterceptor : public grpc::experimental::Interceptor
{
public:
    PerceptionHostAuthInterceptor(grpc::experimental::ClientRpcInfo* info) : m_clientRPCInfoPtr(info)
    {}

    /**
     * 拦截器拦截的方法，它会在很多时机(hook)下拦截，所以叫methods
     * @param methods 多个时机方法
     */
    void Intercept(grpc::experimental::InterceptorBatchMethods* methods) override
    {
        // 客户端接收到消息之后
        // if (methods->QueryInterceptionHookPoint(grpc::experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) {
        //     m_clientRPCInfoPtr->method();
        // }
        // std::cout << "调用了拦截器" << std::endl;
        methods->Proceed();
    }

private:
    grpc::experimental::ClientRpcInfo* m_clientRPCInfoPtr;
};

/**
 * 拦截器，工厂方法
 */
class PerceptionHostAuthInterceptorFactory : public grpc::experimental::ClientInterceptorFactoryInterface
{
public:
    grpc::experimental::Interceptor* CreateClientInterceptor(grpc::experimental::ClientRpcInfo* info) override
    {
        return new PerceptionHostAuthInterceptor(info);
    }
};

PerceptionRPCCallerInstruction::PerceptionRPCCallerInstruction()
{
    // 1、获取感知系统配置信息
    std::string perceptionIP = sys_config::SysConfig::getInstance().perceptionIP();
    std::size_t perceptionPort = sys_config::SysConfig::getInstance().perceptionPort();

    // 2、构建通道参数
    grpc::ChannelArguments channelArguments;
    // 连接感知
    channelArguments.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, 20 * 1000 /*45 sec*/);  // 每隔多长时间发送一次PING
    channelArguments.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, 10 * 1000 /*10 sec*/); // 发送PING后，响应超时时间 [如果发送方在此时间内未收到确认，它将关闭连接]
    channelArguments.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1);    // 是否允许发送心跳数据
    // 断连重接
    channelArguments.SetInt(GRPC_ARG_ENABLE_RETRIES, 1);    // 允许重连
    channelArguments.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 100); // 初次重连间隔时间
    channelArguments.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 100);    // 最小重连间隔时间
    channelArguments.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 100);    // 最大重连间隔时间
    // HTTP2设置
    channelArguments.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0);
    channelArguments.SetInt(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS, 30 * 1000);
    channelArguments.SetInt(GRPC_ARG_HTTP2_BDP_PROBE, 1);
    channelArguments.SetInt(GRPC_ARG_HTTP2_MAX_FRAME_SIZE, 16 * 1024 * 1024); // 16M
    // 内存管理
    channelArguments.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, -1); // 通道可发送的消息最大字节数，-1表示没限制
    channelArguments.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, -1);   // 通道可接受的消息最大字节数，-1表示没限制

    // 3、定义拦截器
    std::vector<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> interceptorCreators;
    // 添加拦截器
    interceptorCreators.push_back(std::make_unique<PerceptionHostAuthInterceptorFactory>());

    // 4、用通道参数创建通道
    std::shared_ptr<grpc::Channel> channel = grpc::experimental::CreateCustomChannelWithInterceptors(
        perceptionIP + ":" + std::to_string(perceptionPort),
        grpc::InsecureChannelCredentials(),
        channelArguments,
        std::move(interceptorCreators)
    );

    // 4、创建远程调用代理(存根对象) 只会被初始化一次
    m_RPCClientStubPtr = network_perception::rpc::NetworkPerceptionServer::NewStub(channel);
    // 构建reactor
    m_RPCClientReactorPtr = std::make_unique<InstructionCallerRPCClientReactor>(m_RPCClientStubPtr.get());
}

void PerceptionRPCCallerInstruction::_handleInstructionResponseResults(RecvInstruction&& instruction) const
{
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    std::int64_t& code = payload.at("code").as_int64();
    boost::json::string& msg = payload.at("msg").as_string();

    if (code != 20000) {
        std::stringstream ss;
        ss << "感知平台响应错误：" << code << " | " << msg;
        throw std::runtime_error(ss.str());
    }

    SPDLOG_INFO("感知平台响应成功...");
}

void PerceptionRPCCallerInstruction::_handleInstructionOpenProbe(RecvInstruction &&instruction) const
{
    // 指令负载
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 观测目标
    auto* probeTasksPtr = payload.at("probeTasks").if_array();

    // 如果返回为空
    if (probeTasksPtr != nullptr) {
        // 将观测目标存入数据表
        std::vector<network_prober::database::ObservedTargetModel> observedTargetModels;

        // 遍历观测目标
        for (auto it = probeTasksPtr->begin(); it != probeTasksPtr->end(); ++it) {
            // 获取观测任务对象
            boost::json::object probeTaskObj = it->as_object();

            // 构建观测模型
            network_prober::database::ObservedTargetModel observedTargetModel;

            observedTargetModel.uuid = probeTaskObj.at("uuid").as_string();    // 设备标识
            observedTargetModel.interface = probeTaskObj.at("interface").as_string();    // 网口名称
            observedTargetModel.address = probeTaskObj.at("address").as_string();  // ip地址
            observedTargetModel.port = probeTaskObj.at("port").as_int64(); // 端口
            observedTargetModel.protocol = probeTaskObj.at("protocol").as_int64();  // 协议 (1:https 2:ICMP 3:TCP 4:UDP 5:PostGreSQL 6:SQL server 7:MySQL 8:MongoDB 9:Redis)
            observedTargetModel.responseCode = probeTaskObj.at("responseCode").as_string(); // 响应码
            observedTargetModel.ignoreTsl = probeTaskObj.at("ignoreTsl").as_bool();  // 是否忽略TSL错误
            observedTargetModel.requestMethod = probeTaskObj.at("requestMethod").as_string();    // 请求方法 (GET、POST、PUT、DELETE、HEAD、OPTIONS、PATCH)
            observedTargetModel.requestHeader = probeTaskObj.at("requestHeader").as_string();    // 请求头
            observedTargetModel.requestBody = probeTaskObj.at("requestBody").as_string();  // 请求体
            observedTargetModel.responseChallenge = probeTaskObj.at("responseChallenge").as_bool();  // 是否身份验证
            observedTargetModel.userName = probeTaskObj.at("userName").as_string(); // 用户名
            observedTargetModel.password = probeTaskObj.at("password").as_string(); // 密码
            observedTargetModel.databaseName = probeTaskObj.at("databaseName").as_string(); // 数据库名称
            observedTargetModel.queryStatement = probeTaskObj.at("queryStatement").as_string();   // 查询语句
            observedTargetModel.matchCondition = probeTaskObj.at("matchCondition").as_bool();   // 是否匹配关键字
            observedTargetModel.keyWords = probeTaskObj.at("keyWords").as_string(); // 关键字

            observedTargetModels.push_back(std::move(observedTargetModel));
        }

        // 批量插入观测目标
        if (!observedTargetModels.empty()) {
            network_prober::database::MemoryDBHolder::getInstance().batchInsertObservedTargets(observedTargetModels);
        }
    }

    // // 备份目标
    // auto* backupTasksPtr = payload.at("backupTasks").if_array();
    //
    // // 如果buckupTasks返回不为null
    // if (backupTasksPtr != nullptr) {
    //     // 将备份目标存入数据表
    //     std::vector<network_prober::database::DeviceModel>  deviceModels;
    //
    //     // 遍历观测目标
    //     for (auto it = backupTasksPtr->begin(); it != backupTasksPtr->end(); ++it) {
    //         // 构建备份目标
    //         network_prober::database::DeviceModel deviceModel;
    //
    //         deviceModel.uuid = it->as_object().at("uuid").as_string();
    //         deviceModel.interface = it->as_object().at("interface").as_string();
    //         deviceModel.address = it->as_object().at("address").as_string();
    //         deviceModel.backupDate = it->as_object().at("backupDate").as_string();
    //         deviceModel.command = it->as_object().at("command").as_string();
    //         deviceModel.protocol = it->as_object().at("protocol").as_int64();
    //         deviceModel.account = it->as_object().at("account").as_string();
    //         deviceModel.password = it->as_object().at("password").as_string();
    //         deviceModel.privilegedPassword = it->as_object().at("privilegedPassword").as_string();
    //         deviceModel.port = it->as_object().at("port").as_int64();
    //
    //         deviceModels.push_back(std::move(deviceModel));
    //     }
    //
    //     // 批量插入备份目标
    //     if (!deviceModels.empty()) {
    //         network_prober::database::MemoryDBHolder::getInstance().batchInsertDevices(deviceModels);
    //     }
    // }

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionOpenProbe ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionCloseProbe(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    // auto payload = boost::json::parse(instruction.payload);

    // 移除探针所有的观测设备
    database::MemoryDBHolder::getInstance().batchRemoveAllObservedTargets();
    // 删除探针所有观测记录
    database::FileDBHolder::getInstance().batchRemoveAllProbeTaskResults();
    // 移除探针所有的备份设备
    database::MemoryDBHolder::getInstance().batchRemoveAllDevices();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionCloseProbe: {}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionOpenNetwork(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 观测目标
    auto& probeTasks = payload.at("probeTasks").as_array();

    // 将观测目标存入数据表
    std::vector<network_prober::database::ObservedTargetModel> observedTargetModels;

    // 遍历观测目标
    for (auto it = probeTasks.begin(); it != probeTasks.end(); ++it) {
        // 构建观测模型
        network_prober::database::ObservedTargetModel observedTargetModel;

        observedTargetModel.uuid = it->as_object().at("uuid").as_string().c_str();
        observedTargetModel.interface = it->as_object().at("interface").as_string().c_str();    // 网口名称
        observedTargetModel.address = it->as_object().at("address").as_string().c_str();  // ip地址
        observedTargetModel.port = it->as_object().at("port").as_int64(); // 端口
        observedTargetModel.protocol = it->as_object().at("protocol").as_int64();  // 协议 (1:https 2:ICMP 3:TCP 4:UDP 5:PostGreSQL 6:SQL server 7:MySQL 8:MongoDB 9:Redis)
        observedTargetModel.responseCode = it->as_object().at("responseCode").as_string().c_str(); // 响应码
        observedTargetModel.ignoreTsl = it->as_object().at("ignoreTsl").as_bool();  // 是否忽略TSL错误
        observedTargetModel.requestMethod = it->as_object().at("requestMethod").as_string().c_str();    // 请求方法 (GET、POST、PUT、DELETE、HEAD、OPTIONS、PATCH)
        observedTargetModel.requestHeader = it->as_object().at("requestHeader").as_string().c_str();    // 请求头
        observedTargetModel.requestBody = it->as_object().at("requestBody").as_string().c_str();  // 请求体
        observedTargetModel.responseChallenge = it->as_object().at("responseChallenge").as_bool();  // 是否身份验证
        observedTargetModel.userName = it->as_object().at("userName").as_string().c_str(); // 用户名
        observedTargetModel.password = it->as_object().at("password").as_string().c_str(); // 密码
        observedTargetModel.databaseName = it->as_object().at("databaseName").as_string().c_str(); // 数据库名称
        observedTargetModel.queryStatement = it->as_object().at("queryStatement").as_string().c_str();   // 查询语句
        observedTargetModel.matchCondition = it->as_object().at("matchCondition").as_bool();    // 是否匹配关键字
        observedTargetModel.keyWords = it->as_object().at("keyWords").as_string().c_str();  // 关键字

        observedTargetModels.push_back(std::move(observedTargetModel));
    }

    // 批量插入观测目标
    if (!observedTargetModels.empty()) {
        network_prober::database::MemoryDBHolder::getInstance().batchInsertObservedTargets(observedTargetModels);
    }

    // 备份目标
    auto& backupTasks = payload.at("backupTasks").as_array();

    // 将备份目标存入数据表
    std::vector<network_prober::database::DeviceModel>  deviceModels;

    // 遍历观测目标
    for (auto it = backupTasks.begin(); it != backupTasks.end(); ++it) {
        // 构建备份目标
        network_prober::database::DeviceModel deviceModel;

        deviceModel.uuid = it->as_object().at("UUID").as_string().c_str();
        deviceModel.interface = it->as_object().at("interface").as_string().c_str();
        deviceModel.address = it->as_object().at("address").as_string().c_str();
        deviceModel.backupDate = it->as_object().at("backupDate").as_string().c_str();
        deviceModel.command = it->as_object().at("command").as_string().c_str();
        deviceModel.protocol = it->as_object().at("protocol").as_int64();
        deviceModel.account = it->as_object().at("account").as_string().c_str();
        deviceModel.password = it->as_object().at("password").as_string().c_str();
        deviceModel.privilegedPassword = it->as_object().at("privilegedPassword").as_string().c_str();
        deviceModel.port = it->as_object().at("port").as_int64();

        deviceModels.push_back(std::move(deviceModel));
    }

    // 批量插入备份目标
    if (!deviceModels.empty()) {
        network_prober::database::MemoryDBHolder::getInstance().batchInsertDevices(deviceModels);
    }

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionOpenNetwork: {}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionCloseNetwork(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 观测设备UUID
    boost::json::array& probeTaskUUIDs = payload.at("probeTaskUUID").as_array();

    // 要删除的设备UUid
    std::vector<std::string> observedTargetUUIDs;
    observedTargetUUIDs.reserve(probeTaskUUIDs.size());

    // 类型转换
    for (auto it = probeTaskUUIDs.begin(); it != probeTaskUUIDs.end(); ++it) {
        observedTargetUUIDs.emplace_back(it->as_string().c_str());
    }

    // 删除网口所属的观测设备
    if (!observedTargetUUIDs.empty()) {
        database::MemoryDBHolder::getInstance().batchRemoveObservedTargetsByUUIDs(observedTargetUUIDs);
    }

    // 备份设备UUID
    boost::json::array& backupTaskUUIDs = payload.at("backupTaskUUID").as_array();

    // 要删除的设备UUid
    std::vector<std::string> deviceUUIDs;
    deviceUUIDs.reserve(backupTaskUUIDs.size());

    // 类型转换
    for (auto it = backupTaskUUIDs.begin(); it != backupTaskUUIDs.end(); ++it) {
        deviceUUIDs.emplace_back(it->as_string().c_str());
    }

    // 删除网口所属的备份设备
    if (!deviceUUIDs.empty()) {
        database::MemoryDBHolder::getInstance().batchRemoveDevicesByUUIDs(deviceUUIDs);
    }

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionCloseNetwork: {}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionICMPProbeDetectIPv4(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 探测网口
    boost::json::string& interface = payload.at("interface").as_string();
    // 要探测的设备ip
    boost::json::string& targets = payload.at("targets").as_string();

    // 将设备ip,按照逗号分隔符解析出来
    std::vector<std::string> targetIPs;
    boost::split(targetIPs, targets, boost::is_any_of(","), boost::token_compress_on);

    // 所有ping结果
    std::vector<probe_detect::ICMPProbeDetectResultIPv4> probeResults;
    probeResults.reserve(targetIPs.size());

    std::mutex probeResultsMutx;
    std::condition_variable probeResultsCv;

    // 遍历设备ip,发送探测请求
    for (const std::string& targetIP : targetIPs) {
        // 创建探测指令对象
        auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleICMPProbeDetectIPv4>(interface.c_str(), targetIP);
        // 监听指令执行结果(延迟了对象生命周期)
        probeDetectInstructionPtr->setOnDetectedCallback([&probeResults, &probeResultsMutx, &probeResultsCv](probe_detect::ICMPProbeDetectResultIPv4&& result) {
            // 保存指令执行结果
            std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
            probeResults.push_back(std::move(result));
            probeResultsCv.notify_one();
        });
        // 执行指令
        probeDetectInstructionPtr->detect();
    }

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
    probeResultsCv.wait(probeResultsLock, [&](){ return probeResults.size() >= targetIPs.size(); });

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_PROBE_DETECT_ICMP_IPV4_DATA);

    // 设定负载
    boost::json::array data;
    for (const auto& probeResult : probeResults) {
        auto jsonProbeResult = boost::json::value_from(probeResult);
        data.push_back(std::move(jsonProbeResult));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionICMPProbeDetectIPv4: {}", dataResp);

    // 负载
    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionICMPProbeDetectIPv6(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 探测网口
    boost::json::string& interface = payload.at("interface").as_string();
    // 要探测的设备ip
    boost::json::string& targets = payload.at("targets").as_string();

    // 将设备ip,按照逗号分隔符解析出来
    std::vector<std::string> targetIPs;
    boost::split(targetIPs, targets, boost::is_any_of(","), boost::token_compress_on);

    // 所有ping结果
    std::vector<probe_detect::ICMPProbeDetectResultIPv6> probeResults;
    probeResults.reserve(targetIPs.size());

    std::mutex probeResultsMutx;
    std::condition_variable probeResultsCv;

    // 遍历设备ip,发送探测请求
    for (const std::string& targetIP : targetIPs) {
        // 创建探测指令对象
        auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleICMPProbeDetectIPv6>(interface.c_str(), targetIP);
        // 监听指令执行结果(延迟了对象生命周期)
        probeDetectInstructionPtr->setOnDetectedCallback([&probeResults, &probeResultsMutx, &probeResultsCv](probe_detect::ICMPProbeDetectResultIPv6&& result) {
            // 保存指令执行结果
            std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
            probeResults.push_back(std::move(result));
            probeResultsCv.notify_one();
        });
        // 执行指令
        probeDetectInstructionPtr->detect();
    }

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
    probeResultsCv.wait(probeResultsLock, [&](){ return probeResults.size() >= targetIPs.size(); });

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_PROBE_DETECT_ICMP_IPV6_DATA);

    // 设定负载
    boost::json::array data;
    for (const auto& probeResult : probeResults) {
        auto jsonProbeResult = boost::json::value_from(probeResult);
        data.push_back(std::move(jsonProbeResult));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionICMPProbeDetectIPv6: {}", dataResp);

    // 负载
    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);

}

void PerceptionRPCCallerInstruction::_handleInstructionTCPProbeDetectIPv4(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 探测网口
    boost::json::string& interface = payload.at("interface").as_string();

    // 要探测的设备ip
    boost::json::array& targets = payload.at("targets").as_array();

    // 将设备ip,按照逗号分隔符解析出来
    // std::vector<std::string> targetURLs;
    // boost::split(targetURLs, targets, boost::is_any_of(","), boost::token_compress_on);

    // 所有ping结果
    std::vector<probe_detect::TCPProbeDetectResultIPv4> probeResults;
    probeResults.reserve(targets.size());    // 避免不断开辟新内存

    std::mutex probeResultsMutx;
    std::condition_variable probeResultsCv;

    // 遍历设备ip,发送探测请求
    for (auto it = targets.begin(); it != targets.end(); ++it) {
        // 探测目标信息
        boost::json::object target = it->as_object();
        // 创建探测指令对象
        auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleTCPProbeDetectIPv4>(interface.c_str(), target.at("target").as_string().c_str(), target.at("port").as_int64());
        // 监听指令执行结果(延迟了对象生命周期)
        probeDetectInstructionPtr->setOnDetectedCallback([&probeResults, &probeResultsMutx, &probeResultsCv](probe_detect::TCPProbeDetectResultIPv4&& result) {
            // 保存指令执行结果
            std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
            probeResults.push_back(std::move(result));
            probeResultsCv.notify_one();
        });
        // 执行指令
        probeDetectInstructionPtr->detect();
    }

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
    probeResultsCv.wait(probeResultsLock, [&](){ return probeResults.size() >= targets.size(); });

    // 指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_PROBE_DETECT_TCP_IPV4_DATA);

    // 设定负载
    boost::json::array data;
    for (const auto& probeResult : probeResults) {
        auto jsonProbeResult = boost::json::value_from(probeResult);
        data.push_back(std::move(jsonProbeResult));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionTCPProbeDetectIPv4: {}", dataResp);

    // 负载
    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionTCPProbeDetectIPv6(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 探测网口
    boost::json::string& interface = payload.at("interface").as_string();
    // 要探测的设备ip
    boost::json::array& targets = payload.at("targets").as_array();

    // 将设备ip,按照逗号分隔符解析出来
    // std::vector<std::string> targetURLs;
    // boost::split(targetURLs, targets, boost::is_any_of(","), boost::token_compress_on);

    // 所有ping结果
    std::vector<probe_detect::TCPProbeDetectResultIPv6> probeResults;
    probeResults.reserve(targets.size());    // 避免不断开辟新内存

    std::mutex probeResultsMutx;
    std::condition_variable probeResultsCv;

    // 遍历设备ip,发送探测请求
    for (auto it = targets.begin(); it != targets.end(); ++it) {
        // 探测信息
        boost::json::object target = it->as_object();
        // 创建探测指令对象
        auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleTCPProbeDetectIPv6>(interface.c_str(), target.at("target").as_string().c_str(), target.at("port").as_int64());
        // 监听指令执行结果(延迟了对象生命周期)
        probeDetectInstructionPtr->setOnDetectedCallback([&probeResults, &probeResultsMutx, &probeResultsCv](probe_detect::TCPProbeDetectResultIPv6&& result) {
            // 保存指令执行结果
            std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
            probeResults.push_back(std::move(result));
            probeResultsCv.notify_one();
        });
        // 执行指令
        probeDetectInstructionPtr->detect();
    }

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
    probeResultsCv.wait(probeResultsLock, [&](){ return probeResults.size() >= targets.size(); });

    // 指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_PROBE_DETECT_TCP_IPV6_DATA);

    // 设定负载
    boost::json::array data;
    for (const auto& probeResult : probeResults) {
        auto jsonProbeResult = boost::json::value_from(probeResult);
        data.push_back(std::move(jsonProbeResult));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionTCPProbeDetectIPv6: {}", dataResp);

    // 负载
    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUDPProbeDetectIPv4(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 探测网口
    boost::json::string& interface = payload.at("interface").as_string();
    // 要探测的设备ip
    boost::json::array& targets = payload.at("targets").as_array();

    // 将设备ip,按照逗号分隔符解析出来
    // std::vector<std::string> targetURLs;
    // boost::split(targetURLs, targets, boost::is_any_of(","), boost::token_compress_on);

    // 所有ping结果
    std::vector<probe_detect::UDPProbeDetectResultIPv4> probeResults;
    probeResults.reserve(targets.size());

    std::mutex probeResultsMutx;
    std::condition_variable probeResultsCv;

    // 遍历设备ip,发送探测请求
    for (auto it = targets.begin(); it != targets.end(); ++it) {
        // 探测信息
        boost::json::object target = it->as_object();
        // 创建探测指令对象
        auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleUDPProbeDetectIPv4>(interface.c_str(), target.at("target").as_string().c_str(), target.at("port").as_int64());
        // 监听指令执行结果(延迟了对象生命周期)
        probeDetectInstructionPtr->setOnDetectedCallback([&probeResults, &probeResultsMutx, &probeResultsCv](probe_detect::UDPProbeDetectResultIPv4&& result) {
            // 保存指令执行结果
            std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
            probeResults.push_back(std::move(result));
            probeResultsCv.notify_one();
        });
        // 执行指令
        probeDetectInstructionPtr->detect();
    }

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
    probeResultsCv.wait(probeResultsLock, [&](){ return probeResults.size() >= targets.size(); });

    // 指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_PROBE_DETECT_UDP_IPV4_DATA);

    // 设定负载
    boost::json::array data;
    for (const auto& probeResult : probeResults) {
        auto jsonProbeResult = boost::json::value_from(probeResult);
        data.push_back(std::move(jsonProbeResult));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUDPProbeDetectIPv4: {}", dataResp);

    // 负载
    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUDPProbeDetectIPv6(RecvInstruction &&instruction) const
{
    // 将json解析成对象
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 探测网口
    boost::json::string& interface = payload.at("interface").as_string();
    // 要探测的设备ip
    boost::json::array& targets = payload.at("targets").as_array();

    // 将设备ip,按照逗号分隔符解析出来
    // std::vector<std::string> targetURLs;
    // boost::split(targetURLs, targets, boost::is_any_of(","), boost::token_compress_on);

    // 所有ping结果
    std::vector<probe_detect::UDPProbeDetectResultIPv6> probeResults;
    probeResults.reserve(targets.size());

    std::mutex probeResultsMutx;
    std::condition_variable probeResultsCv;

    // 遍历设备ip,发送探测请求
    for (auto it = targets.begin(); it != targets.end(); ++it) {
        // 探测信息
        boost::json::object target = it->as_object();
        // 创建探测指令对象
        auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleUDPProbeDetectIPv6>(interface.c_str(), target.at("target").as_string().c_str(), target.at("port").as_int64());
        // 监听指令执行结果(延迟了对象生命周期)
        probeDetectInstructionPtr->setOnDetectedCallback([&probeResults, &probeResultsMutx, &probeResultsCv](probe_detect::UDPProbeDetectResultIPv6&& result) {
            // 保存指令执行结果
            std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
            probeResults.push_back(std::move(result));
            probeResultsCv.notify_one();
        });
        // 执行指令
        probeDetectInstructionPtr->detect();
    }

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultsMutx);
    probeResultsCv.wait(probeResultsLock, [&](){ return probeResults.size() >= targets.size(); });

    // 指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_PROBE_DETECT_UDP_IPV6_DATA);

    // 设定负载
    boost::json::array data;
    for (const auto& probeResult : probeResults) {
        boost::json::value jsonProbeResult = boost::json::value_from(probeResult);
        data.push_back(std::move(jsonProbeResult));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUDPProbeDetectIPv6: {}", dataResp);

    // 负载
    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionPipeManagementProbeTargets(RecvInstruction &&instruction) const
{
    // 指令负载
    auto payload = boost::json::parse(instruction.payload);

    // 观测目标
    auto& probeTargets = payload.as_array();

    // 将观测目标存入数据表
    std::vector<network_prober::database::ObservedTargetModel> observedTargetModels;
    observedTargetModels.reserve(probeTargets.size()); // 开辟出n个元素的空间

    // 遍历观测目标
    for (auto it = probeTargets.begin(); it != probeTargets.end(); ++it) {
        // 构建观测模型
        network_prober::database::ObservedTargetModel observedTargetModel;

        observedTargetModel.uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate());    // 设备标识
        observedTargetModel.interface = it->as_object().at("interface").as_string();    // 网口名称
        observedTargetModel.address = it->as_object().at("address").as_string();  // ip地址
        observedTargetModel.port = it->as_object().at("port").as_int64(); // 端口
        observedTargetModel.protocol = it->as_object().at("protocol").as_int64();  // 协议 (1:https 2:ICMP 3:TCP 4:UDP 5:PostGreSQL 6:SQL server 7:MySQL 8:MongoDB 9:Redis)
        observedTargetModel.responseCode = it->as_object().at("responseCode").as_string(); // 响应码
        observedTargetModel.ignoreTsl = it->as_object().at("ignoreTsl").as_bool();  // 是否忽略TSL错误
        observedTargetModel.requestMethod = it->as_object().at("requestMethod").as_string();    // 请求方法 (GET、POST、PUT、DELETE、HEAD、OPTIONS、PATCH)
        observedTargetModel.requestHeader = it->as_object().at("requestHeader").as_string();    // 请求头
        observedTargetModel.requestBody = it->as_object().at("requestBody").as_string();  // 请求体
        observedTargetModel.responseChallenge = it->as_object().at("responseChallenge").as_bool();  // 是否身份验证
        observedTargetModel.userName = it->as_object().at("userName").as_string(); // 用户名
        observedTargetModel.password = it->as_object().at("password").as_string(); // 密码
        observedTargetModel.databaseName = it->as_object().at("databaseName").as_string(); // 数据库名称
        observedTargetModel.queryStatement = it->as_object().at("queryStatement").as_string();   // 查询语句

        observedTargetModels.push_back(std::move(observedTargetModel));
    }

    // 批量插入观测目标
    network_prober::database::MemoryDBHolder::getInstance().batchInsertObservedTargets(observedTargetModels);

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_PIPE_MANAGEMENT_PROBE_TARGETS_DATA);

    // 设定负载
    boost::json::array data;
    for (const auto& observedTargetModel : observedTargetModels) {
        boost::json::object object;

        object["target"] = observedTargetModel.address;
        object["port"] = observedTargetModel.port;
        object["UUID"] = observedTargetModel.uuid;

        data.push_back(std::move(object));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionPipeManagementProbeTargets: {}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddICMPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"address":"192.168.0.1","interface":"192.168.0.101","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 探测
    probe_detect::ICMPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleICMPProbeDetectIPv4>(observedTarget.interface, observedTarget.address);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::ICMPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_ICMP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddICMPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddICMPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 探测
    probe_detect::ICMPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleICMPProbeDetectIPv6>(observedTarget.interface, observedTarget.address);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::ICMPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_ICMP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp{boost::json::serialize(data)};

    SPDLOG_INFO("响应 _handleInstructionAddICMPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateICMPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 探测
    probe_detect::ICMPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleICMPProbeDetectIPv4>(observedTarget.interface, observedTarget.address);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::ICMPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_ICMP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateICMPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateICMPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 探测
    probe_detect::ICMPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleICMPProbeDetectIPv6>(observedTarget.interface, observedTarget.address);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::ICMPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_ICMP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateICMPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddTCPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::TCPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleTCPProbeDetectIPv4>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::TCPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_TCP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddTCPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddTCPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::TCPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleTCPProbeDetectIPv6>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::TCPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_TCP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddTCPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateTCPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::TCPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleTCPProbeDetectIPv4>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::TCPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_TCP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateTCPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateTCPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::TCPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleTCPProbeDetectIPv6>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::TCPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_TCP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateTCPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddUDPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::UDPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleUDPProbeDetectIPv4>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::UDPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_UDP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddUDPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddUDPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::UDPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleUDPProbeDetectIPv6>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::UDPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_UDP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddUDPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateUDPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::UDPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleUDPProbeDetectIPv4>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::UDPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_UDP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateUDPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateUDPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 所有ping结果
    probe_detect::UDPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleUDPProbeDetectIPv6>(observedTarget.interface, observedTarget.address, observedTarget.port);
    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::UDPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_UDP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateUDPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddHTTPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    probe_detect::HTTPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_HTTP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddHTTPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddHTTPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    probe_detect::HTTPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_HTTP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddHTTPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateHTTPProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    auto payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    probe_detect::HTTPProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_HTTP_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateHTTPProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateHTTPProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    probe_detect::HTTPProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_HTTP_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateHTTPProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddHTTPSProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    probe_detect::HTTPSProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPSProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPSProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_HTTPS_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddHTTPSProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddHTTPSProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    probe_detect::HTTPSProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPSProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPSProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_HTTPS_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddHTTPSProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddMySQLProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MySQLProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMySQLProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MySQLProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_MYSQL_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddMySQLProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddMySQLProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MySQLProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMySQLProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MySQLProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_MYSQL_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddMySQLProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddPostgreSQLProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::PostgreSQLProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandlePostgreSQLProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::PostgreSQLProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_POSTGRESQL_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddPostgreSQLProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddPostgreSQLProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::PostgreSQLProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandlePostgreSQLProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::PostgreSQLProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_POSTGRESQL_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddPostgreSQLProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddSQLServerProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::SQLServerProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleSQLServerProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::SQLServerProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_SQLSERVER_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddSQLServerProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddSQLServerProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::SQLServerProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleSQLServerProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::SQLServerProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_SQLSERVER_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddSQLServerProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddMongoDBProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MongoDBProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMongoDBProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MongoDBProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_MONGODB_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddMongoDBProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddMongoDBProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MongoDBProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMongoDBProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MongoDBProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_MONGODB_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddMongoDBProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateMongoDBProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MongoDBProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMongoDBProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MongoDBProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_MONGODB_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateMongoDBProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateMongoDBProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MongoDBProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMongoDBProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MongoDBProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_MONGODB_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateMongoDBProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddRedisProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::RedisProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleRedisProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::RedisProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_REDIS_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddRedisProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddRedisProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::RedisProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleRedisProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::RedisProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_REDIS_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddRedisProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateRedisProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::RedisProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleRedisProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::RedisProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_REDIS_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateRedisProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateRedisProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::RedisProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleRedisProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::RedisProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_REDIS_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateRedisProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);

}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateHTTPSProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    probe_detect::HTTPSProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPSProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPSProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_HTTPS_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateHTTPSProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateHTTPSProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    probe_detect::HTTPSProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleHTTPSProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.responseCode,
        observedTarget.ignoreTsl,
        observedTarget.requestMethod, //  目标端口
        observedTarget.requestHeader,  // 地址类型 ipv4/ipv6
        observedTarget.requestBody,
        observedTarget.responseChallenge,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.matchCondition,
        observedTarget.keyWords
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::HTTPSProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_HTTPS_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateHTTPSProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateMySQLProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MySQLProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMySQLProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MySQLProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_MYSQL_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateMySQLProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateMySQLProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::MySQLProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleMySQLProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::MySQLProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_MYSQL_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateMySQLProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdatePostgreSQLProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::PostgreSQLProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandlePostgreSQLProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::PostgreSQLProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_POSTGRESQL_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdatePostgreSQLProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdatePostgreSQLProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::PostgreSQLProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandlePostgreSQLProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::PostgreSQLProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_POSTGRESQL_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdatePostgreSQLProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateSQLServerProbeTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::SQLServerProbeDetectResultIPv4 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleSQLServerProbeDetectIPv4>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::SQLServerProbeDetectResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_SQLSERVER_IPV4_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateSQLServerProbeTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateSQLServerProbeTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"en01","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
    };
    database::MemoryDBHolder::getInstance().updateObservedTarget(observedTarget);

    // 做一次探测
    probe_detect::SQLServerProbeDetectResultIPv6 probeResult;
    std::mutex probeResultMutx;
    std::condition_variable probeResultsCv;

    // 创建探测指令对象
    auto probeDetectInstructionPtr = std::make_shared<probe_detect::HandleSQLServerProbeDetectIPv6>(
        observedTarget.interface,
        observedTarget.address,
        observedTarget.port,
        observedTarget.userName,
        observedTarget.password,
        observedTarget.databaseName,
        observedTarget.queryStatement
    );

    // 监听指令执行结果(延迟了对象生命周期)
    probeDetectInstructionPtr->setOnDetectedCallback([&probeResult, &probeResultMutx, &probeResultsCv](probe_detect::SQLServerProbeDetectResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
        probeResult = std::move(result);
        probeResultsCv.notify_one();
    });
    // 执行指令
    probeDetectInstructionPtr->detect();

    // 等待ping请求完成
    std::unique_lock<std::mutex> probeResultsLock(probeResultMutx);
    probeResultsCv.wait(probeResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_UPDATE_SQLSERVER_IPV6_PROBE_TARGET_DATA);

    // 设定负载 {"UUID":"uuid","delay":20, "probeTime":"1235526549" }
    boost::json::object data = {
        {"UUID", observedTarget.uuid},
        {"delay", probeResult.delay},
        {"probeTime", std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateSQLServerProbeTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}


void PerceptionRPCCallerInstruction::_handleInstructionDeleteProbeTarget(RecvInstruction &&instruction) const
{
    // 指令负载
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 观测设备标识
    boost::json::string& uuid = payload.at("UUID").as_string();

    // 删除观测设备
    database::MemoryDBHolder::getInstance().removeObservedTargetByUUID(uuid);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载 {"code":"20000","msg":"SUCCESS"}
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionDeleteProbeTarget ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionBatchDeleteProbeTarget(RecvInstruction &&instruction) const
{
    // 指令负载
    boost::json::array payload = boost::json::parse(instruction.payload).as_array();

    std::vector<std::string> uuids;
    uuids.reserve(payload.size());

    for (auto it = payload.begin(); it != payload.end(); ++it) {
        uuids.emplace_back(it->as_string().c_str());
    }

    database::MemoryDBHolder::getInstance().batchRemoveObservedTargetsByUUIDs(uuids);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载 {"code":"20000","msg":"SUCCESS"}
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionBatchDeleteProbeTarget ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionBatchImportProbeTarget(RecvInstruction &&instruction) const
{
    // 指令负载 [{"interface":"192.168.0.1","address":"192.168.0.101","port":8848,"protocol":1,"responseCode":"","ignoreTsl":false,"requestMethod":"","requestHeader":"","requestBody":"","responseChallenge":false,"userName":"","password":"","databaseName":"","queryStatement":""}]
    boost::json::value payload = boost::json::parse(instruction.payload);

    // 观测目标
    boost::json::array& probeTargets = payload.as_array();

    // 将观测目标存入数据表
    std::vector<network_prober::database::ObservedTargetModel> observedTargetModels;
    observedTargetModels.reserve(probeTargets.size()); // 开辟出n个元素的空间

    // 遍历观测目标
    for (auto it = probeTargets.begin(); it != probeTargets.end(); ++it) {
        // 构建观测模型
        network_prober::database::ObservedTargetModel observedTargetModel;

        boost::json::object& probeTarget = it->as_object();

        observedTargetModel.uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate());    // 设备标识
        observedTargetModel.interface = probeTarget.at("interface").as_string();    // 网口名称
        observedTargetModel.address = probeTarget.at("address").as_string();  // ip地址
        observedTargetModel.port = probeTarget.at("port").as_int64(); // 端口
        observedTargetModel.protocol = probeTarget.at("protocol").as_int64();  // 协议 (1:https 2:ICMP 3:TCP 4:UDP 5:PostGreSQL 6:SQL server 7:MySQL 8:MongoDB 9:Redis)
        observedTargetModel.responseCode = probeTarget.at("responseCode").as_string(); // 响应码
        observedTargetModel.ignoreTsl = probeTarget.at("ignoreTsl").as_bool();  // 是否忽略TSL错误
        observedTargetModel.requestMethod = probeTarget.at("requestMethod").as_string();    // 请求方法 (GET、POST、PUT、DELETE、HEAD、OPTIONS、PATCH)
        observedTargetModel.requestHeader = probeTarget.at("requestHeader").as_string();    // 请求头
        observedTargetModel.requestBody = probeTarget.at("requestBody").as_string();  // 请求体
        observedTargetModel.responseChallenge = probeTarget.at("responseChallenge").as_bool();  // 是否身份验证
        observedTargetModel.userName = probeTarget.at("userName").as_string(); // 用户名
        observedTargetModel.password = probeTarget.at("password").as_string(); // 密码
        observedTargetModel.databaseName = probeTarget.at("databaseName").as_string(); // 数据库名称
        observedTargetModel.queryStatement = probeTarget.at("queryStatement").as_string();   // 查询语句
        observedTargetModel.matchCondition = probeTarget.at("matchCondition").as_bool();    // 是否关键字匹配
        observedTargetModel.keyWords = probeTarget.at("keyWords").as_string();  // 匹配的关键字

        observedTargetModels.push_back(std::move(observedTargetModel));
    }

    // 批量插入观测目标
    network_prober::database::MemoryDBHolder::getInstance().batchInsertObservedTargets(observedTargetModels);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_BATCH_IMPORT_PROBE_TARGET_DATA);

    // 设定负载
    boost::json::array data;
    data.reserve(observedTargetModels.size());

    // 遍历每个元素
    for (const auto& observedTargetModel : observedTargetModels) {
        // 观测目标
        boost::json::object object;

        object["uuid"] = observedTargetModel.uuid;
        object["interface"] = observedTargetModel.interface;
        object["address"] = observedTargetModel.address;
        object["port"] = observedTargetModel.port;
        object["protocol"] = observedTargetModel.protocol;
        object["responseCode"] = observedTargetModel.responseCode;
        object["ignoreTsl"] = observedTargetModel.ignoreTsl;
        object["requestMethod"] = observedTargetModel.requestMethod;
        object["requestHeader"] = observedTargetModel.requestHeader;
        object["requestBody"] = observedTargetModel.requestBody;
        object["responseChallenge"] = observedTargetModel.responseChallenge;
        object["userName"] = observedTargetModel.userName;
        object["password"] = observedTargetModel.password;
        object["databaseName"] = observedTargetModel.databaseName;
        object["queryStatement"] = observedTargetModel.queryStatement;
        object["matchCondition"] = observedTargetModel.matchCondition;
        object["keyWords"] = observedTargetModel.keyWords;

        data.push_back(std::move(object));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionBatchImportProbeTarget: {}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionDetailsProbeTarget(RecvInstruction &&instruction) const
{
    // 指令负载 {startTime:"1752871150", "endTime":"1752871150", targets:["uuid", "uuid"]}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 开始时间
    auto& startTime = payload.at("startTime").as_string();
    // 结束时间
    auto& endTime = payload.at("endTime").as_string();
    // 观测目标
    auto& targets = payload.at("targets").as_array();

    std::vector<std::string> uuids;
    uuids.reserve(targets.size());

    for (auto it = targets.begin(); it != targets.end(); ++it) {
        uuids.emplace_back(it->as_string());
    }

    // 获取观测结果
    auto probeTaskResults = database::FileDBHolder::getInstance().getProbeTaskResultsByUUIDsAndStartEndTime(uuids, startTime, endTime);

    // 指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_DETAILS_PROBE_TARGET_DATA);

    // 设定负载
    boost::json::array data;
    for (auto it = probeTaskResults.begin(); it != probeTaskResults.end(); ++it) {
        boost::json::object result;

        result["uuid"] = it->uuid;
        result["delay"] = it->delay;
        result["packetLossRate"] = it->packetLossRate;
        result["probeTime"] = it->probeTime;

        data.push_back(std::move(result));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionDetailsProbeTarget: {}", dataResp);

    // 负载
    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionTimeSynchronizaton(RecvInstruction &&instruction) const
{
    // 指令负载 {"time":"1723256523"}
    boost::json::object&& payload = boost::json::parse(instruction.payload).as_object();

    boost::json::string& time = payload.at("time").as_string();

    // 修改系统时间
    struct timeval tv;
    tv.tv_sec = std::stol(time.c_str()); // 时间戳
    tv.tv_usec = 0; // 微秒部分设置为0

    // 设置系统时间，注：这里要记得先运行命令关闭自动对时：sudo timedatectl set-ntp no
    if (settimeofday(&tv, NULL) < 0) {
        SPDLOG_ERROR("系统时间设置失败...");
        throw std::runtime_error("系统时间设置失败...");
    }

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionTimeSynchronizaton ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionOpenProbeTarget(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid", "interface":"192.168.0.10","address":"192.168.0.101","port":8848,"responseCode":"200","ignoreTsl":true,"requestMethod":"GET","requestHeader":"{"Content-Type":"application/json"}","requestBody":"{"id":10}","responseChallenge":true,"userName":"admin","password":"123456admin","databaseName":"dev_tw","queryStatement":"SELECT * FROM xxx"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::ObservedTargetModel observedTarget{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .responseCode = payload["responseCode"].as_string().c_str(),
        .ignoreTsl = payload["ignoreTsl"].as_bool(),
        .requestMethod = payload["requestMethod"].as_string().c_str(),
        .requestHeader = payload["requestHeader"].as_string().c_str(),
        .requestBody = payload["requestBody"].as_string().c_str(),
        .responseChallenge = payload["responseChallenge"].as_bool(),
        .userName = payload["userName"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .databaseName = payload["databaseName"].as_string().c_str(),
        .queryStatement = payload["queryStatement"].as_string().c_str(),
        .matchCondition = payload.at("matchCondition").as_bool(),
        .keyWords = payload.at("keyWords").as_string().c_str()
    };
    database::MemoryDBHolder::getInstance().insertObservedTarget(observedTarget);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionOpenProbeTarget ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionCloseProbeTarget(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 观测设备标识
    boost::json::string& uuid = payload.at("UUID").as_string();

    // 删除观测设备
    database::MemoryDBHolder::getInstance().removeObservedTargetByUUID(uuid);
    // 删除观测设备对应的观测记录
    database::FileDBHolder::getInstance().batchRemoveProbeTaskResultsByTargetUUID(uuid);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载 {"code":"20000","msg":"SUCCESS"}
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionCloseProbeTarget ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionTestTELNETBackupTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"address":"192.168.0.1","interface":"192.168.0.101", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    auto& interface = payload["interface"].as_string();
    auto& target = payload["address"].as_string();
    auto& port = payload["port"].as_int64();
    auto& username = payload["account"].as_string();
    auto& password = payload["password"].as_string();
    auto& privilegedPassword = payload["privilegedPassword"].as_string();
    auto& command = payload["command"].as_string();

    // 探测
    backup_test::TELNETBackupTestResultIPv4 testResult;
    std::mutex testResultMutx;
    std::condition_variable testResultsCv;

    // 测试参数
    backup_test::TELNETBackupTestParamsIPv4 testParams{
        .interface=interface,
        .target=target,
        .port=static_cast<std::uint16_t>(port),
        .username=username,
        .password=password,
        .privilegedPassword=privilegedPassword,
        .command=command
    };

    // 创建探测指令对象
    auto backupTestInstructionPtr = std::make_shared<backup_test::HandleTELNETBackupTestIPv4>(std::move(testParams));

    // 监听指令执行结果(延迟了对象生命周期)
    backupTestInstructionPtr->setOnTestedCallback([&testResult, &testResultMutx, &testResultsCv](backup_test::TELNETBackupTestResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(testResultMutx);
        testResult = std::move(result);
        testResultsCv.notify_one();
    });

    // 执行指令
    backupTestInstructionPtr->test();

    // 等待完成
    std::unique_lock<std::mutex> testResultsLock(testResultMutx);
    testResultsCv.wait(testResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_TEST_TELNET_IPV4_BACKUP_TARGET_DATA);

    // 设定负载 {"interface":"","target": "", "port":0, "backupData": ""}
    boost::json::object data = {
        {"interface", testResult.interface},
        {"target", testResult.target},
        {"port", testResult.port},
        {"backupData", testResult.backupData}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionTestTELNETBackupTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionTestTELNETBackupTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"address":"192.168.0.1","interface":"192.168.0.101", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    auto& interface = payload["interface"].as_string();
    auto& target = payload["address"].as_string();
    auto& port = payload["port"].as_int64();
    auto& username = payload["username"].as_string();
    auto& password = payload["password"].as_string();
    auto& privilegedPassword = payload["privilegedPassword"].as_string();
    auto& command = payload["command"].as_string();

    // 探测
    backup_test::TELNETBackupTestResultIPv6 testResult;
    std::mutex testResultMutx;
    std::condition_variable testResultsCv;

    // 测试参数
    backup_test::TELNETBackupTestParamsIPv6 testParams{
        .interface=interface,
        .target=target,
        .port=static_cast<std::uint16_t>(port),
        .username=username,
        .password=password,
        .privilegedPassword=privilegedPassword,
        .command=command
    };

    // 创建探测指令对象
    auto backupTestInstructionPtr = std::make_shared<backup_test::HandleTELNETBackupTestIPv6>(std::move(testParams));

    // 监听指令执行结果(延迟了对象生命周期)
    backupTestInstructionPtr->setOnTestedCallback([&testResult, &testResultMutx, &testResultsCv](backup_test::TELNETBackupTestResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(testResultMutx);
        testResult = std::move(result);
        testResultsCv.notify_one();
    });

    // 执行指令
    backupTestInstructionPtr->test();

    // 等待完成
    std::unique_lock<std::mutex> testResultsLock(testResultMutx);
    testResultsCv.wait(testResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_TEST_TELNET_IPV6_BACKUP_TARGET_DATA);

    // 设定负载 {"interface":"","target": "", "port":0, "backupData": ""}
    boost::json::object data = {
        {"interface", testResult.interface},
        {"target", testResult.target},
        {"port", testResult.port},
        {"backupData", testResult.backupData}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionTestTELNETBackupTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionTestSSHBackupTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"address":"192.168.0.1","interface":"192.168.0.101", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    auto& interface = payload["interface"].as_string();
    auto& target = payload["address"].as_string();
    auto& port = payload["port"].as_int64();
    auto& account = payload["account"].as_string();
    auto& password = payload["password"].as_string();
    auto& privilegedPassword = payload["privilegedPassword"].as_string();
    auto& command = payload["command"].as_string();

    // 探测
    backup_test::SSHBackupTestResultIPv4 testResult;
    std::mutex testResultMutx;
    std::condition_variable testResultsCv;

    // 测试参数
    backup_test::SSHBackupTestParamsIPv4 testParams{
        .interface=interface,
        .target=target,
        .port=static_cast<std::uint16_t>(port),
        .username=account,
        .password=password,
        .privilegedPassword=privilegedPassword,
        .command=command
    };

    // 创建探测指令对象
    auto backupTestInstructionPtr = std::make_shared<backup_test::HandleSSHBackupTestIPv4>(std::move(testParams));

    // 监听指令执行结果(延迟了对象生命周期)
    backupTestInstructionPtr->setOnTestedCallback([&testResult, &testResultMutx, &testResultsCv](backup_test::SSHBackupTestResultIPv4&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(testResultMutx);
        testResult = std::move(result);
        testResultsCv.notify_one();
    });

    // 执行指令
    backupTestInstructionPtr->test();

    // 等待完成
    std::unique_lock<std::mutex> testResultsLock(testResultMutx);
    testResultsCv.wait(testResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_TEST_SSH_IPV4_BACKUP_TARGET_DATA);

    // 设定负载 {"interface":"","target": "", "port":0, "backupData": ""}
    boost::json::object data = {
        {"interface", testResult.interface},
        {"target", testResult.target},
        {"port", testResult.port},
        {"backupData", testResult.backupData}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionTestSSHBackupTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionTestSSHBackupTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"address":"192.168.0.1","interface":"192.168.0.101", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    auto& interface = payload["interface"].as_string();
    auto& target = payload["address"].as_string();
    auto& port = payload["port"].as_int64();
    auto& account = payload["account"].as_string();
    auto& password = payload["password"].as_string();
    auto& privilegedPassword = payload["privilegedPassword"].as_string();
    auto& command = payload["command"].as_string();

    // 探测
    backup_test::SSHBackupTestResultIPv6 testResult;
    std::mutex testResultMutx;
    std::condition_variable testResultsCv;

    // 测试参数
    backup_test::SSHBackupTestParamsIPv6 testParams{
        .interface=interface,
        .target=target,
        .port=static_cast<std::uint16_t>(port),
        .username=account,
        .password=password,
        .privilegedPassword=privilegedPassword,
        .command=command
    };

    // 创建探测指令对象
    auto backupTestInstructionPtr = std::make_shared<backup_test::HandleSSHBackupTestIPv6>(std::move(testParams));

    // 监听指令执行结果(延迟了对象生命周期)
    backupTestInstructionPtr->setOnTestedCallback([&testResult, &testResultMutx, &testResultsCv](backup_test::SSHBackupTestResultIPv6&& result) {
        // 保存指令执行结果
        std::unique_lock<std::mutex> probeResultsLock(testResultMutx);
        testResult = std::move(result);
        testResultsCv.notify_one();
    });

    // 执行指令
    backupTestInstructionPtr->test();

    // 等待完成
    std::unique_lock<std::mutex> testResultsLock(testResultMutx);
    testResultsCv.wait(testResultsLock);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_TEST_SSH_IPV6_BACKUP_TARGET_DATA);

    // 设定负载 {"interface":"","target": "", "port":0, "backupData": ""}
    boost::json::object data = {
        {"interface", testResult.interface},
        {"target", testResult.target},
        {"port", testResult.port},
        {"backupData", testResult.backupData}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionTestSSHBackupTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddSSHBackupTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    database::MemoryDBHolder::getInstance().insertDevice(device);

    // 存储当前目标的备份内容
    database::MemoryDBHolder::getInstance().insertBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_SSH_IPV4_BACKUP_TARGET_DATA);

    // 设定负载
    boost::json::object data = {
        {"UUID", device.uuid}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddSSHBackupTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddSSHBackupTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    database::MemoryDBHolder::getInstance().insertDevice(device);

    // 存储当前目标的备份内容
    database::MemoryDBHolder::getInstance().insertBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_SSH_IPV6_BACKUP_TARGET_DATA);

    // 设定负载
    boost::json::object data = {
        {"UUID", device.uuid}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddSSHBackupTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateSSHBackupTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"12:30:15", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    // 更新备份目标
    database::MemoryDBHolder::getInstance().updateDevice(device);

    // 更新备份目标的备份内容
    database::MemoryDBHolder::getInstance().updateBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateSSHBackupTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateSSHBackupTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"12:30:15", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    // 更新备份目标
    database::MemoryDBHolder::getInstance().updateDevice(device);

    // 更新备份目标的备份内容
    database::MemoryDBHolder::getInstance().updateBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateSSHBackupTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddTELNETBackupTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    database::MemoryDBHolder::getInstance().insertDevice(device);

    // 存储当前目标的备份内容
    database::MemoryDBHolder::getInstance().insertBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_TELNET_IPV4_BACKUP_TARGET_DATA);

    // 设定负载
    boost::json::object data = {
        {"UUID", device.uuid}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddTELNETBackupTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionAddTELNETBackupTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"interface":"192.168.0.101","address":"192.168.0.1","backupDate":"1234567891","command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    database::MemoryDBHolder::getInstance().insertDevice(device);

    // 存储当前目标的备份内容
    database::MemoryDBHolder::getInstance().insertBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_ADD_TELNET_IPV6_BACKUP_TARGET_DATA);

    // 设定负载
    boost::json::object data = {
        {"UUID", device.uuid}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionAddTELNETBackupTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateTELNETBackupTargetIPv4(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"12:30:15", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    // 更新备份目标
    database::MemoryDBHolder::getInstance().updateDevice(device);

    // 更新备份目标的备份内容
    database::MemoryDBHolder::getInstance().updateBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateTELNETBackupTargetIPv4 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionUpdateTELNETBackupTargetIPv6(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"12:30:15", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 构建模型 存入数据库
    database::DeviceModel device{
        .uuid = payload["UUID"].as_string().c_str(),
        .interface = payload["interface"].as_string().c_str(),
        .address = payload["address"].as_string().c_str(),
        .backupDate = payload["backupDate"].as_string().c_str(),
        .command = payload["command"].as_string().c_str(),
        .protocol = static_cast<std::uint32_t>(payload["protocol"].as_int64()),
        .account = payload["account"].as_string().c_str(),
        .password = payload["password"].as_string().c_str(),
        .privilegedPassword = payload["privilegedPassword"].as_string().c_str(),
        .port = static_cast<std::uint32_t>(payload["port"].as_int64()),
    };
    // 更新备份目标
    database::MemoryDBHolder::getInstance().updateDevice(device);

    // 更新备份目标的备份内容
    database::MemoryDBHolder::getInstance().updateBackupTaskResult(device.uuid, payload["backupData"].as_string().c_str(), std::chrono::time_point_cast<std::chrono::seconds>(std::chrono::system_clock::now()).time_since_epoch().count());

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionUpdateTELNETBackupTargetIPv6 ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionDeleteBackupTarget(RecvInstruction &&instruction) const
{
    // 指令负载 {"UUID":"uuid"}
    boost::json::object payload = boost::json::parse(instruction.payload).as_object();

    // 备份设备标识
    boost::json::string& uuid = payload.at("UUID").as_string();

    // 删除备份设备内容
    database::MemoryDBHolder::getInstance().removeBackupTaskResultByUUID(uuid);
    // 删除备份设备
    database::MemoryDBHolder::getInstance().removeDeviceByUUID(uuid);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_RESPONSE_RESULTS);

    // 设定负载 {"code":"20000","msg":"SUCCESS"}
    boost::json::object data = {
        {"code", 20000},
        {"msg", "SUCCESS"}
    };

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionDeleteBackupTarget ：{}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::_handleInstructionBatchImportBackupTarget(RecvInstruction &&instruction) const
{
    // 指令负载 [{"uuid":"uuid","interface":"192.168.0.101","address":"192.168.0.1","backupDate":"12:30:15", "protocol": 1,"command":"mkdir test","account":"admin","password":"123456","privilegedPassword":"admin123456","port":8080}]
    boost::json::value payload = boost::json::parse(instruction.payload);

    // 备份目标
    boost::json::array& backupTargets = payload.as_array();

    // 将备份目标存入数据表
    std::vector<network_prober::database::DeviceModel> backupTargetModels;
    backupTargetModels.reserve(backupTargets.size()); // 开辟出n个元素的空间

    // 遍历备份目标
    for (auto it = backupTargets.begin(); it != backupTargets.end(); ++it) {
        // 备份目标
        boost::json::object& target = it->as_object();

        // 构建备份目标模型
        network_prober::database::DeviceModel backupTargetModel {
            .uuid = std::to_string(utils::SnowflakeUUIDGenerator::getInstance().generate()),    // 设备标识
            .interface = target["interface"].as_string().c_str(),   // 网口名称
            .address = target["address"].as_string().c_str(),   // ip地址
            .backupDate = target["backupDate"].as_string().c_str(), // 备份日期
            .command = target["command"].as_string().c_str(),   // 备份命令
            .protocol = static_cast<std::uint32_t>(target["protocol"].as_int64()),  // 备份协议
            .account = target["account"].as_string().c_str(),   // 登录账号
            .password = target["password"].as_string().c_str(), // 登录密码
            .privilegedPassword = target["privilegedPassword"].as_string().c_str(), // 特权码
            .port = static_cast<std::uint32_t>(target["port"].as_int64())  // 端口
        };

        backupTargetModels.push_back(std::move(backupTargetModel));
    }

    // 批量插入备份目标
    network_prober::database::MemoryDBHolder::getInstance().batchInsertDevices(backupTargetModels);

    // 清空指令
    m_RPCClientReactorPtr->instructionRequest.Clear();

    // 设定指令
    m_RPCClientReactorPtr->instructionRequest.set_instruction(network_perception::rpc::InstructionRequest_InstructionType_BATCH_IMPORT_BACKUP_TARGET_DATA);

    // 设定负载
    boost::json::array data;
    data.reserve(backupTargetModels.size());

    // 遍历每个元素
    for (const auto& backupTargetModel : backupTargetModels) {
        // 观测目标
        boost::json::object object;

        object["uuid"] = backupTargetModel.uuid;
        object["interface"] = backupTargetModel.interface;
        object["address"] = backupTargetModel.address;
        object["backupDate"] = backupTargetModel.backupDate;
        object["command"] = backupTargetModel.command;
        object["protocol"] = backupTargetModel.protocol;
        object["account"] = backupTargetModel.account;
        object["password"] = backupTargetModel.password;
        object["privilegedPassword"] = backupTargetModel.privilegedPassword;
        object["port"] = backupTargetModel.port;

        data.push_back(std::move(object));
    }

    std::string dataResp = boost::json::serialize(data);

    SPDLOG_INFO("响应 _handleInstructionBatchImportBackupTarget: {}", dataResp);

    m_RPCClientReactorPtr->instructionRequest.set_data(dataResp);

    // 向平台发送指令
    m_RPCClientReactorPtr->StartWrite(&m_RPCClientReactorPtr->instructionRequest);
}

void PerceptionRPCCallerInstruction::callImpl()
{
    // 启动指令处理线程
    // 开启一个线程，不断从无锁队列中获取服务端指令（起初肯定是空的），根据获取的指令选择对应的处理程序
    std::jthread instructionHandleThread([this]() {
        // 未处理指令
        RecvInstruction recvInstruction;
        // 监听指令队列
        while (1) {
            // 当指令队列中没有未处理的指令时，等待
            while (!g_instructionSpscQueue.pop(&recvInstruction)) {}

            // 检测到未处理指令时，处理指令
            // 响应指令，表示平台给探针返回了某个指令处理的结果
            if (recvInstruction.instructionType == InstructionType::RESPONSE_RESULTS) {
                SPDLOG_INFO("指令 RESPONSE_RESULTS: {}", recvInstruction.payload);
                _handleInstructionResponseResults(std::move(recvInstruction));
            }
            // 启用探针
            else if (recvInstruction.instructionType == InstructionType::OPEN_PROBE) {
                SPDLOG_INFO("指令 OPEN_PROBE: {}", recvInstruction.payload);
                _handleInstructionOpenProbe(std::move(recvInstruction));
            }
            // 关闭探针
            else if (recvInstruction.instructionType == InstructionType::CLOSE_PROBE) {
                SPDLOG_INFO("指令 CLOSE_PROBE: {}", recvInstruction.payload);
                _handleInstructionCloseProbe(std::move(recvInstruction));
            }
            // 启动网口
            else if (recvInstruction.instructionType == InstructionType::OPEN_NETWORK) {
                SPDLOG_INFO("指令 OPEN_NETWORK: {}", recvInstruction.payload);
                _handleInstructionOpenNetwork(std::move(recvInstruction));
            }
            // 关闭网口
            else if (recvInstruction.instructionType == InstructionType::CLOSE_NETWORK) {
                SPDLOG_INFO("指令 CLOSE_NETWORK: {}", recvInstruction.payload);
                _handleInstructionCloseNetwork(std::move(recvInstruction));
            }
            // 探测观测目标 ICMP ipv4
            else if (recvInstruction.instructionType == InstructionType::PROBE_DETECT_ICMP_IPV4) {
                SPDLOG_INFO("指令 PROBE_DETECT_ICMP_IPV4: {}", recvInstruction.payload);
                _handleInstructionICMPProbeDetectIPv4(std::move(recvInstruction));
            }
            // 探测观测目标 ICMP ipv6
            else if (recvInstruction.instructionType == InstructionType::PROBE_DETECT_ICMP_IPV6) {
                SPDLOG_INFO("指令 PROBE_DETECT_ICMP_IPV6: {}", recvInstruction.payload);
                _handleInstructionICMPProbeDetectIPv6(std::move(recvInstruction));
            }
            // 探测观测目标 TCP ipv4
            else if (recvInstruction.instructionType == InstructionType::PROBE_DETECT_TCP_IPV4) {
                SPDLOG_INFO("指令 PROBE_DETECT_TCP_IPV4: {}", recvInstruction.payload);
                _handleInstructionTCPProbeDetectIPv4(std::move(recvInstruction));
            }
            // 探测观测目标 TCP ipv6
            else if (recvInstruction.instructionType == InstructionType::PROBE_DETECT_TCP_IPV6) {
                SPDLOG_INFO("指令 PROBE_DETECT_TCP_IPV6: {}", recvInstruction.payload);
                _handleInstructionTCPProbeDetectIPv6(std::move(recvInstruction));
            }
            // 探测观测目标 UDP ipv4
            else if (recvInstruction.instructionType == InstructionType::PROBE_DETECT_UDP_IPV4) {
                SPDLOG_INFO("指令 PROBE_DETECT_UDP_IPV4: {}", recvInstruction.payload);
                _handleInstructionUDPProbeDetectIPv4(std::move(recvInstruction));
            }
            // 探测观测目标 UDP ipv6
            else if (recvInstruction.instructionType == InstructionType::PROBE_DETECT_UDP_IPV6) {
                SPDLOG_INFO("指令 PROBE_DETECT_UDP_IPV6: {}", recvInstruction.payload);
                _handleInstructionUDPProbeDetectIPv6(std::move(recvInstruction));
            }
            // 納管观测目标
            else if (recvInstruction.instructionType == InstructionType::PIPE_MANAGEMENT_PROBE_TARGETS) {
                SPDLOG_INFO("指令 PIPE_MANAGEMENT_PROBE_TARGETS: {}", recvInstruction.payload);
                _handleInstructionPipeManagementProbeTargets(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 icmp
            else if (recvInstruction.instructionType == InstructionType::ADD_ICMP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_ICMP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddICMPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 icmp
            else if (recvInstruction.instructionType == InstructionType::ADD_ICMP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_ICMP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddICMPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 tcp
            else if (recvInstruction.instructionType == InstructionType::ADD_TCP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_ICMP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddTCPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 tcp
            else if (recvInstruction.instructionType == InstructionType::ADD_TCP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_TCP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddTCPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 udp
            else if (recvInstruction.instructionType == InstructionType::ADD_UDP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_UDP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddUDPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 udp
            else if (recvInstruction.instructionType == InstructionType::ADD_UDP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_UDP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddUDPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 http
            else if (recvInstruction.instructionType == InstructionType::ADD_HTTP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_HTTP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddHTTPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 http
            else if (recvInstruction.instructionType == InstructionType::ADD_HTTP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_HTTP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddHTTPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 https
            else if (recvInstruction.instructionType == InstructionType::ADD_HTTPS_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_HTTPS_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddHTTPSProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 https
            else if (recvInstruction.instructionType == InstructionType::ADD_HTTPS_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_HTTPS_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddHTTPSProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 MySQL
            else if (recvInstruction.instructionType == InstructionType::ADD_MYSQL_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_MYSQL_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddMySQLProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 MySQL
            else if (recvInstruction.instructionType == InstructionType::ADD_MYSQL_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_MYSQL_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddMySQLProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 PostgreSQL
            else if (recvInstruction.instructionType == InstructionType::ADD_POSTGRESQL_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_POSTGRESQL_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddPostgreSQLProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 PostgreSQL
            else if (recvInstruction.instructionType == InstructionType::ADD_POSTGRESQL_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_POSTGRESQL_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddPostgreSQLProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 SQLServer
            else if (recvInstruction.instructionType == InstructionType::ADD_SQLSERVER_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_SQLSERVER_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddSQLServerProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 SQLServer
            else if (recvInstruction.instructionType == InstructionType::ADD_SQLSERVER_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_SQLSERVER_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddSQLServerProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 MongoDB
            else if (recvInstruction.instructionType == InstructionType::ADD_MONGODB_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_MONGODB_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddMongoDBProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 MongoDB
            else if (recvInstruction.instructionType == InstructionType::ADD_MONGODB_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_MONGODB_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddMongoDBProbeTargetIPv6(std::move(recvInstruction));
            }
            // 添加观测目标 ipv4 Redis
            else if (recvInstruction.instructionType == InstructionType::ADD_REDIS_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_REDIS_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddRedisProbeTargetIPv4(std::move(recvInstruction));
            }
            // 添加观测目标 ipv6 Redis
            else if (recvInstruction.instructionType == InstructionType::ADD_REDIS_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 ADD_REDIS_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddRedisProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 icmp
            else if (recvInstruction.instructionType == InstructionType::UPDATE_ICMP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_ICMP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateICMPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 icmp
            else if (recvInstruction.instructionType == InstructionType::UPDATE_ICMP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_ICMP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateICMPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 tcp
            else if (recvInstruction.instructionType == InstructionType::UPDATE_TCP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_TCP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateTCPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 tcp
            else if (recvInstruction.instructionType == InstructionType::UPDATE_TCP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_TCP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateTCPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 udp
            else if (recvInstruction.instructionType == InstructionType::UPDATE_UDP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_UDP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateUDPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 udp
            else if (recvInstruction.instructionType == InstructionType::UPDATE_UDP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_UDP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateUDPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 HTTP
            else if (recvInstruction.instructionType == InstructionType::UPDATE_HTTP_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_HTTP_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateHTTPProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 HTTP
            else if (recvInstruction.instructionType == InstructionType::UPDATE_HTTP_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_HTTP_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateHTTPProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 HTTPS
            else if (recvInstruction.instructionType == InstructionType::UPDATE_HTTPS_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_HTTPS_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateHTTPSProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 HTTPS
            else if (recvInstruction.instructionType == InstructionType::UPDATE_HTTPS_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_HTTPS_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateHTTPSProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 MySQL
            else if (recvInstruction.instructionType == InstructionType::UPDATE_MYSQL_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_MYSQL_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateMySQLProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 MySQL
            else if (recvInstruction.instructionType == InstructionType::UPDATE_MYSQL_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_MYSQL_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateMySQLProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 PostgreSQL
            else if (recvInstruction.instructionType == InstructionType::UPDATE_POSTGRESQL_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_POSTGRESQL_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdatePostgreSQLProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 PostgreSQL
            else if (recvInstruction.instructionType == InstructionType::UPDATE_POSTGRESQL_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_POSTGRESQL_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdatePostgreSQLProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 SQLServer
            else if (recvInstruction.instructionType == InstructionType::UPDATE_SQLSERVER_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_SQLSERVER_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateSQLServerProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 SQLServer
            else if (recvInstruction.instructionType == InstructionType::UPDATE_SQLSERVER_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_SQLSERVER_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateSQLServerProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 MongoDB
            else if (recvInstruction.instructionType == InstructionType::UPDATE_MONGODB_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_MONGODB_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateMongoDBProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 MongoDB
            else if (recvInstruction.instructionType == InstructionType::UPDATE_MONGODB_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_MONGODB_IPV6_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateMongoDBProbeTargetIPv6(std::move(recvInstruction));
            }
            // 更新观测目标 ipv4 Redis
            else if (recvInstruction.instructionType == InstructionType::UPDATE_REDIS_IPV4_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_REDIS_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateRedisProbeTargetIPv4(std::move(recvInstruction));
            }
            // 更新观测目标 ipv6 Redis
            else if (recvInstruction.instructionType == InstructionType::UPDATE_REDIS_IPV6_PROBE_TARGET) {
                SPDLOG_INFO("指令 UPDATE_REDIS_IPV4_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateRedisProbeTargetIPv6(std::move(recvInstruction));
            }
            // 删除观测目标
            else if (recvInstruction.instructionType == InstructionType::DELETE_PROBE_TARGET) {
                SPDLOG_INFO("指令 DELETE_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionDeleteProbeTarget(std::move(recvInstruction));
            }
            // 批量删除观测目标
            else if (recvInstruction.instructionType == InstructionType::BATCH_DELETE_PROBE_TARGET) {
                SPDLOG_INFO("指令 BATCH_DELETE_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionBatchDeleteProbeTarget(std::move(recvInstruction));
            }
            // 导入观测目标
            else if (recvInstruction.instructionType == InstructionType::BATCH_IMPORT_PROBE_TARGET) {
                SPDLOG_INFO("指令 BATCH_IMPORT_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionBatchImportProbeTarget(std::move(recvInstruction));
            }
            // 设备详情(趋势图)
            else if (recvInstruction.instructionType == InstructionType::DETAILS_PROBE_TARGET) {
                SPDLOG_INFO("指令 DETAILS_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionDetailsProbeTarget(std::move(recvInstruction));
            }
            // 开启观测目标
            else if (recvInstruction.instructionType == InstructionType::OPEN_PROBE_TARGET) {
                SPDLOG_INFO("指令 OPEN_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionOpenProbeTarget(std::move(recvInstruction));
            }
            // 关闭观测目标
            else if (recvInstruction.instructionType == InstructionType::CLOSE_PROBE_TARGET) {
                SPDLOG_INFO("指令 CLOSE_PROBE_TARGET: {}", recvInstruction.payload);
                _handleInstructionCloseProbeTarget(std::move(recvInstruction));
            }
            // 系统时钟同步
            else if (recvInstruction.instructionType == InstructionType::TIME_SYNCHRONIZATION) {
                SPDLOG_INFO("指令 TIME_SYNCHRONIZATION: {}", recvInstruction.payload);
                _handleInstructionTimeSynchronizaton(std::move(recvInstruction));
            }
            // 测试TELNET_Ipv4备份目标
            else if (recvInstruction.instructionType == InstructionType::TEST_TELNET_IPV4_BACKUP_TARGET) {
                SPDLOG_INFO("指令 TEST_TELNET_IPV4_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionTestTELNETBackupTargetIPv4(std::move(recvInstruction));
            }
            // 测试TELNET_Ipv6备份目标
            else if (recvInstruction.instructionType == InstructionType::TEST_TELNET_IPV6_BACKUP_TARGET) {
                SPDLOG_INFO("指令 TEST_TELNET_IPV6_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionTestTELNETBackupTargetIPv6(std::move(recvInstruction));
            }
            // 测试SSH_Ipv4备份目标
            else if (recvInstruction.instructionType == InstructionType::TEST_SSH_IPV4_BACKUP_TARGET) {
                SPDLOG_INFO("指令 TEST_SSH_IPV4_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionTestSSHBackupTargetIPv4(std::move(recvInstruction));
            }
            // 测试SSH_Ipv6备份目标
            else if (recvInstruction.instructionType == InstructionType::TEST_SSH_IPV6_BACKUP_TARGET) {
                SPDLOG_INFO("指令 TEST_SSH_IPV6_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionTestSSHBackupTargetIPv6(std::move(recvInstruction));
            }
            // 添加TELNET_Ipv4备份目标
            else if (recvInstruction.instructionType == InstructionType::ADD_TELNET_IPV4_BACKUP_TARGET) {
                SPDLOG_INFO("指令 ADD_TELNET_IPV4_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddTELNETBackupTargetIPv4(std::move(recvInstruction));
            }
            // 添加TELNET_Ipv6备份目标
            else if (recvInstruction.instructionType == InstructionType::ADD_TELNET_IPV6_BACKUP_TARGET) {
                SPDLOG_INFO("指令 ADD_TELNET_IPV6_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddTELNETBackupTargetIPv6(std::move(recvInstruction));
            }
            // 修改TELNET_Ipv4备份目标
            else if (recvInstruction.instructionType == InstructionType::UPDATE_TELNET_IPV4_BACKUP_TARGET) {
                SPDLOG_INFO("指令 UPDATE_TELNET_IPV4_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateTELNETBackupTargetIPv4(std::move(recvInstruction));
            }
            // 修改TELNET_Ipv6备份目标
            else if (recvInstruction.instructionType == InstructionType::UPDATE_TELNET_IPV6_BACKUP_TARGET) {
                SPDLOG_INFO("指令 UPDATE_TELNET_IPV6_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateTELNETBackupTargetIPv6(std::move(recvInstruction));
            }
            // 测试SSH_Ipv4备份目标
            else if (recvInstruction.instructionType == InstructionType::TEST_SSH_IPV4_BACKUP_TARGET) {
                SPDLOG_INFO("指令 TEST_SSH_IPV4_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionTestSSHBackupTargetIPv4(std::move(recvInstruction));
            }
            // 测试SSH_Ipv6备份目标
            else if (recvInstruction.instructionType == InstructionType::TEST_SSH_IPV6_BACKUP_TARGET) {
                SPDLOG_INFO("指令 TEST_SSH_IPV6_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionTestSSHBackupTargetIPv6(std::move(recvInstruction));
            }
            // 添加SSH_Ipv4备份目标
            else if (recvInstruction.instructionType == InstructionType::ADD_SSH_IPV4_BACKUP_TARGET) {
                SPDLOG_INFO("指令 ADD_SSH_IPV4_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddSSHBackupTargetIPv4(std::move(recvInstruction));
            }
            // 添加SSH_Ipv6备份目标
            else if (recvInstruction.instructionType == InstructionType::ADD_SSH_IPV6_BACKUP_TARGET) {
                SPDLOG_INFO("指令 ADD_SSH_IPV6_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionAddSSHBackupTargetIPv6(std::move(recvInstruction));
            }
            // 修改SSH_Ipv4备份目标
            else if (recvInstruction.instructionType == InstructionType::UPDATE_SSH_IPV4_BACKUP_TARGET) {
                SPDLOG_INFO("指令 UPDATE_SSH_IPV4_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateSSHBackupTargetIPv4(std::move(recvInstruction));
            }
            // 修改SSH_Ipv6备份目标
            else if (recvInstruction.instructionType == InstructionType::UPDATE_SSH_IPV6_BACKUP_TARGET) {
                SPDLOG_INFO("指令 UPDATE_SSH_IPV6_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionUpdateSSHBackupTargetIPv6(std::move(recvInstruction));
            }
            // 删除备份目标
            else if (recvInstruction.instructionType == InstructionType::DELETE_BACKUP_TARGET) {
                SPDLOG_INFO("指令 DELETE_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionDeleteBackupTarget(std::move(recvInstruction));
            }
            // 批量导入备份目标
            else if (recvInstruction.instructionType == InstructionType::BATCH_IMPORT_BACKUP_TARGET) {
                SPDLOG_INFO("指令 BATCH_IMPORT_BACKUP_TARGET: {}", recvInstruction.payload);
                _handleInstructionBatchImportBackupTarget(std::move(recvInstruction));
            }
        }
    });

    // instruction双向流通道的状态
    grpc::Status grpcChannelStatus;
    do {
        // 开启grpc双向流通道，准备接收指令，建立通道
        m_RPCClientReactorPtr->startCalling();

        // 等待双向流通道关闭（监听变量）
        grpcChannelStatus = m_RPCClientReactorPtr->awaitCallingDone();

        // 如果正常结束则停止
        if (grpcChannelStatus.ok()) break;

        // 如果没有正常结束，则重新发起连接
        // 日志输出
        SPDLOG_INFO("instruction 双向流未正常结束: {} - {}，重新发起连接..", static_cast<std::int8_t>(grpcChannelStatus.error_code()), grpcChannelStatus.error_message());

        // 1、获取感知系统配置信息
        std::string perceptionIP = sys_config::SysConfig::getInstance().perceptionIP();
        std::size_t perceptionPort = sys_config::SysConfig::getInstance().perceptionPort();
        // 2、构建通道参数
        grpc::ChannelArguments channelArguments;
        // 连接感知
        channelArguments.SetInt(GRPC_ARG_KEEPALIVE_TIME_MS, 20 * 1000 /*45 sec*/);  // 每隔多长时间发送一次PING
        channelArguments.SetInt(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, 10 * 1000 /*10 sec*/); // 发送PING后，响应超时时间 [如果发送方在此时间内未收到确认，它将关闭连接]
        channelArguments.SetInt(GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS, 1);    // 是否允许发送心跳数据
        // 断连重接
        channelArguments.SetInt(GRPC_ARG_ENABLE_RETRIES, 1);    // 允许重连
        channelArguments.SetInt(GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS, 100); // 初次重连间隔时间
        channelArguments.SetInt(GRPC_ARG_MIN_RECONNECT_BACKOFF_MS, 100);    // 最小重连间隔时间
        channelArguments.SetInt(GRPC_ARG_MAX_RECONNECT_BACKOFF_MS, 100);    // 最大重连间隔时间
        // HTTP2设置
        channelArguments.SetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, 0);
        channelArguments.SetInt(GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS, 30 * 1000);
        channelArguments.SetInt(GRPC_ARG_HTTP2_BDP_PROBE, 1);
        channelArguments.SetInt(GRPC_ARG_HTTP2_MAX_FRAME_SIZE, 16 * 1024 * 1024); // 16M
        // 内存管理
        channelArguments.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, -1); // 通道可发送的消息最大字节数，-1表示没限制
        channelArguments.SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, -1);   // 通道可接受的消息最大字节数，-1表示没限制
        // 3、定义拦截器
        std::vector<std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> interceptorCreators;
        // 添加拦截器
        interceptorCreators.push_back(std::make_unique<PerceptionHostAuthInterceptorFactory>());
        // 4、用通道参数创建通道
        std::shared_ptr<grpc::Channel> channel = grpc::experimental::CreateCustomChannelWithInterceptors(
            perceptionIP + ":" + std::to_string(perceptionPort),
            grpc::InsecureChannelCredentials(),
            channelArguments,
            std::move(interceptorCreators)
        );
        // 5、创建远程调用代理(存根对象) 只会被初始化一次
        m_RPCClientStubPtr = network_perception::rpc::NetworkPerceptionServer::NewStub(channel);
        // 构建reactor
        m_RPCClientReactorPtr = std::make_unique<InstructionCallerRPCClientReactor>(m_RPCClientStubPtr.get());

    } while (!grpcChannelStatus.ok());

    // 连接当前线程
    // instructionHandleThread.join();
}

}